/**
 * Created by Administrator on 2016/6/22 0022.
 */
import React from 'react';
import ReactDom from 'react-dom';
import $ from 'webpack-zepto';
import Config from '../common/config.js';
import Util from '../common/util.js';
import ViewCarousel from './view/viewCarousel.js';
import GoodsView from './view/goods-view.js';


var goods_common_id = Util.getUrlParam('goods_common_id');
var appId = Util.appId();
var token = Util.storage().get(appId);
$.get(Config.path('duolu/goods', ['?common_id=' + goods_common_id, '&uToken=' + token]), function (resp) {
//    if(!resp || resp.status != 200){
//    return;
//}
////if (resp.status == 401) {
////    var appid = Util.getUrlParam('appid');
////    window.location.href = 'index.html?appid=' + appid;
////}
    if(resp.status == 200){
        ReactDom.render(
            <div className="goods-view">
                <ViewCarousel data={resp.data.detail_img}></ViewCarousel>
                <GoodsView data={resp.data} appId={appId}></GoodsView>
            </div>,
            document.getElementById('goodsView')
        );
    }else if(resp.status == 401){
        window.location.href = 'index.html?appid=' + appId;
        alert('token丢失！');
        return;
    }else{
        return;
    }

});
